#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
void ITOB(int n, char s[], int b)
{
	char arr[36] = { '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
	int j = 0;
	s[100] = '\0';
	int ns = n;
	if (n < 0)
		n = -n;
	int m = 99;
	while (n != 0)
	{
		int i = n % b;
		for (j = 0; j < 36; j++)
		{
			if (j == i)
			{
				s[m] = arr[j];
				m--;
				break;
			}
		}
		n /= b;
	}
	if (ns < 0)
	{
		s[m] = '-';
	}
	if (ns >= 0)
		printf("%s", &s[m + 1]);
	else
		printf("%s", &s[m ]);
}
int main()
{
	char s[101] = { 0 };
	int n = 0;
	int b = 0;
	scanf("%d %d", &n, &b);
	ITOB(n, s, b);
	return 0;
}